#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

void solve() {
    int n, k;
    cin >> n >> k;
    int a = 0, b = 0, c = 0, d = 0;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(i == 0) a = x, b = y;
        c += x, d += y;
    }
    cout << 2 * (c + k - a) + 2 * (d + k - b) << endl;
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}